package com.lianzai.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.Optional;

public class ParamsUtils {
	
	public static String map2StrByAscii(Map<String,String> map) {
		StringBuffer sign = new StringBuffer("");
		Optional.ofNullable(map).ifPresent( m -> {
			m.keySet().forEach(k -> {
				boolean b = sign.length() > 0 ;
				String value = m.get(k);
				if(StringUtils.isNotBlank(value) && !"sign".equals(k) && !"mac".equals(k))
				sign.append( (b ? "&" :"").concat(k).concat("=").concat(value));
			});
		});
		return sign.toString();
	}

}
